package com.wutuo.classroom.provider.base;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.classroom.provider.domain.LearningClassroom;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 学堂 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

@MapperAnnotation public interface BaseLearningClassroomMapper
    extends GenericMapper<LearningClassroom, Long> {

    @Override @Delete({"delete from learning_classroom", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override
    @Insert({"insert into learning_classroom (", "user_id,", "cm_institution_id,", "learning_type,",
        "learning_title,", "learning_object,", "teacher,", "institution,", "learning_photo,",
        "page_num,", "recommended_index,", "create_by,", "learning_pdf,", "learning_image,",
        "learning_office,", "create_date,", "update_by,", "update_date,", "remarks,", "del_flag,",
        "year,", "state", " )values(", "#{userId,jdbcType=BIGINT},",
        "#{cmInstitutionId,jdbcType=BIGINT},", "#{learningType,jdbcType=VARCHAR},",
        "#{learningTitle,jdbcType=VARCHAR},", "#{learningObject,jdbcType=VARCHAR},",
        "#{teacher,jdbcType=VARCHAR},", "#{institution,jdbcType=VARCHAR},",
        "#{learningPhoto,jdbcType=VARCHAR},", "#{pageNum,jdbcType=BIGINT},",
        "#{recommendedIndex,jdbcType=VARCHAR},", "#{createBy,jdbcType=BIGINT},",
        "#{learningPdf,jdbcType=VARCHAR},", "#{learningImage,jdbcType=VARCHAR},",
        "#{learningOffice,jdbcType=VARCHAR},", "#{createDate,jdbcType=VARCHAR},",
        "#{updateBy,jdbcType=BIGINT},", "#{updateDate,jdbcType=VARCHAR},",
        "#{remarks,jdbcType=VARCHAR},", "#{delFlag,jdbcType=VARCHAR},", "#{year,jdbcType=BIGINT},",
        "#{state,jdbcType=VARCHAR})"}) int insert(LearningClassroom record);

    @InsertProvider(type = BaseLearningClassroomSqlProvider.class, method = "insertSelective")
    int insertSelective(LearningClassroom record);

    @Override
    @Select({"select", "user_id,", "learning_type,", "cm_institution_id,", "learning_title,",
        "learning_object,", "teacher,", "institution,", "learning_photo,", "page_num,",
        "recommended_index,", "create_by,", "learning_pdf,", "learning_image,", "learning_office,",
        "create_date,", "update_by,", "update_date,", "remarks,", "del_flag,", "year,", "state",
        "from learning_classroom", "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        @Result(column = "user_id", property = "userId", jdbcType = JdbcType.BIGINT),
        @Result(column = "learning_type", property = "learningType", jdbcType = JdbcType.VARCHAR),
        @Result(column = "cm_institution_id", property = "cmInstitutionId", jdbcType = JdbcType.BIGINT),
        @Result(column = "learning_title", property = "learningTitle", jdbcType = JdbcType.VARCHAR),
        @Result(column = "learning_object", property = "learningObject", jdbcType = JdbcType.VARCHAR),
        @Result(column = "teacher", property = "teacher", jdbcType = JdbcType.VARCHAR),
        @Result(column = "institution", property = "institution", jdbcType = JdbcType.VARCHAR),
        @Result(column = "learning_photo", property = "learningPhoto", jdbcType = JdbcType.VARCHAR),
        @Result(column = "page_num", property = "pageNum", jdbcType = JdbcType.BIGINT),
        @Result(column = "recommended_index", property = "recommendedIndex", jdbcType = JdbcType.VARCHAR),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "learning_pdf", property = "learningPdf", jdbcType = JdbcType.VARCHAR),
        @Result(column = "learning_image", property = "learningImage", jdbcType = JdbcType.VARCHAR),
        @Result(column = "learning_office", property = "learningOffice", jdbcType = JdbcType.VARCHAR),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.VARCHAR),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.VARCHAR),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR),
        @Result(column = "year", property = "year", jdbcType = JdbcType.BIGINT),
        @Result(column = "state", property = "state", jdbcType = JdbcType.VARCHAR)})
    LearningClassroom selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseLearningClassroomSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(LearningClassroom record);

    @Override @Update({"update learning_classroom", "set ", "user_id = #{userId,jdbcType=BIGINT},",
        "cm_institution_id = #{cmInstitutionId,jdbcType=BIGINT},",
        "learning_title = #{learningTitle,jdbcType=VARCHAR},",
        "learning_object = #{learningObject,jdbcType=VARCHAR},",
        "teacher = #{teacher,jdbcType=VARCHAR},", "institution = #{institution,jdbcType=VARCHAR},",
        "learning_photo = #{learningPhoto,jdbcType=VARCHAR},",
        "page_num = #{pageNum,jdbcType=BIGINT},",
        "recommended_index = #{recommendedIndex,jdbcType=VARCHAR},",
        "create_by = #{createBy,jdbcType=BIGINT},",
        "learning_pdf = #{learningPdf,jdbcType=VARCHAR},",
        "learning_image = #{learningImage,jdbcType=VARCHAR},",
        "learning_office = #{learningOffice,jdbcType=VARCHAR},",
        "create_date = #{createDate,jdbcType=VARCHAR},", "update_by = #{updateBy,jdbcType=BIGINT},",
        "update_date = #{updateDate,jdbcType=VARCHAR},", "remarks = #{remarks,jdbcType=VARCHAR},",
        "del_flag = #{delFlag,jdbcType=VARCHAR},", "year = #{year,jdbcType=BIGINT},",
        "learning_type = #{learningType,jdbcType=VARCHAR},", "state = #{state,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"}) int updateByPrimaryKey(LearningClassroom record);
}